package com.smartaccounting.service;

import com.smartaccounting.dao.BudgetDAO;
import com.smartaccounting.model.Budget;

import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.List;

public class BudgetService {
    private BudgetDAO budgetDAO;

    public BudgetService() {
        this.budgetDAO = new BudgetDAO();
    }

    public boolean addBudget(Budget budget) throws SQLException {
        return budgetDAO.addBudget(budget);
    }

    public boolean updateBudget(Budget budget) throws SQLException {
        return budgetDAO.updateBudget(budget);
    }

    public boolean deleteBudget(int budgetId) throws SQLException {
        return budgetDAO.deleteBudget(budgetId);
    }

    public List<Budget> getUserBudgets(int userId) throws SQLException {
        return budgetDAO.getBudgetsByUserId(userId);
    }

    public List<Budget> getUserBudgetsByMonth(int userId, String monthYear) throws SQLException {
        return budgetDAO.getBudgetsByUserIdAndMonth(userId, monthYear);
    }

    public BigDecimal getTotalBudgetByMonth(int userId, String monthYear) throws SQLException {
        return budgetDAO.getTotalBudgetByUserIdAndMonth(userId, monthYear);
    }

    public Budget getBudgetByCategoryAndMonth(int userId, String category, String monthYear) throws SQLException {
        return budgetDAO.getBudgetByUserCategoryAndMonth(userId, category, monthYear);
    }
}